import { http } from "@/utils/http";
import httpConfig from "@/utils/http/httpConfig";
const prefix = httpConfig.pms;

/**
 * 获取
 * @param params
 */
export function ProductList(params?: Record<string, any>) {
  return http.post(prefix + "/spu/page", { data: params });
}

/**
 * 添加
 * @param params
 * @returns {*}
 */
export function ProductAdd(params: Record<string, any>) {
  return http.post(prefix + "/spu/add", { data: params });
}

/**
 * 修改
 * @param params
 * @returns {*}
 */
export function ProductEdit(params: Record<string, any>) {
  return http.post(prefix + "/product/edit", { data: params });
}

/**
 * 删除
 * @param params
 * @returns {*}
 */
export function ProductDelete(params: Record<string, any>) {
  return http.post(prefix + "/product/del", { data: params });
}

/**
 * 获取详情
 * @param params
 * @returns {*}
 */
export function ProductDetail(params: any) {
  console.log("params", params);

  return http.get(prefix + "/spu/detail?spuId=" + params.spuId, params);
}

/**
 * 获取审核记录
 * @param productId
 */
export function ProductApproveList(productId: any) {
  return http.get(prefix + "/spu/approve/list/" + productId);
}

/**
 * 上下架商品
 * @param productId  spuid
 * @param publishStatus  上下架状态
 * @returns
 */
export function offOrPublish(productId: String, publishStatus: Number) {
  return http.post(prefix + "/spu/offOrPublish", {
    params: { productId, publishStatus }
  });
}

/**
 * 审核商品
 * @param productId  商品id
 * @param remark  反馈信息
 * @param status 状态
 * @returns
 */
export function approve(data: any) {
  return http.post(prefix + "/spu/approve", {
    data
  });
}

/**
 * 修改sku库存
 * @param spuId  商品id
 * @param skuList  sku列表
 * @returns
 */
export function skuEditStockAndPrice(spuId: any, skuList: any) {
  return http.post(prefix + "/spu/sku/edit/" + spuId, {
    data: skuList
  });
}
